package loengud.w09;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

import loengud.w09.ButtonExampleFrame.HelloWorldButtonListener;

public class AnonymousClassExample extends JFrame {

	JLabel lbl;
	public AnonymousClassExample() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(300, 300);
		getContentPane().setLayout(new FlowLayout());
		
		JButton button1 = new JButton("hello");
		// let's add a new anonymous class as the listener
		button1.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				lbl.setText("World 2!");
			}
		});
		getContentPane().add(button1);
		
		lbl = new JLabel("tere");
		getContentPane().add(lbl);
	}
	public static void main(String[] args) {
		AnonymousClassExample f = new AnonymousClassExample();
		f.setVisible(true);
	}

}
